home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / Little Smalltalk v3.1.4 / Smalltalk Source / notifier.st < prev    next >
Encoding:
Text File  |  1995-01-26  |  2.1 KB  |  85 lines  |  [TEXT/KAHL]

  1. * ***
  2. * Methods for a system error notifier
  3. *
  4. * Julian Barkway (c) October 1994. All rights reserved. 
  5. *
  6. * v3.1.3    Initial release.
  7. *
  8. * ***
  9. Class Notifier Object nWindow pMenu theText
  10.  
  11. "Process::trace modified to write results to a string"
  12.  
  13. Methods Process 'tracing'
  14.     traceToMem    | link m r s |
  15.         " first yield scheduler, forcing store of linkPointer"
  16.         scheduler yield.
  17.         linkPointer isNil ifTrue: [
  18.             ^ 'No trace-back data available'
  19.         ].
  20.         link <- linkPointer.
  21.         link <- stack at: link + 1.
  22.         s    <- ''.
  23.         " then trace back chain "
  24.         [ link notNil ] whileTrue: [
  25.             m <- stack at: link + 3. 
  26.             m notNil ifTrue: [ 
  27.                 s <- s , (m signature) , ' ( '.
  28.                   r <- stack at: link + 2.
  29.                   (r to: link-1) do: [:x | 
  30.                       s <- s, ((stack at: x) class asString), ' '
  31.                   ].
  32.                 s <- s, ')', newLine 
  33.             ].
  34.             link <- stack at: link
  35.         ].
  36.         ^ s
  37. ]
  38.  
  39. Methods Smalltalk 'doit'
  40.     error: aString    | s txt |
  41.         " print a message, and remove current process "
  42.         txt <- scheduler currentProcess traceToMem.
  43.         Notifier new; notify: aString withText: txt.
  44.         (scheduler currentProcess) terminate
  45. ]
  46.  
  47. Methods Notifier 'all'
  48.     notify: titleText withText: text
  49.         theText <- text.
  50.         self makeWindow: titleText
  51. |        
  52.     makeWindow: aTitle
  53.     | maxW maxH topCentre origin |
  54.         maxW <- (smalltalk getMaxScreenArea) right.
  55.         maxH <- (smalltalk getMaxScreenArea) bottom.
  56.         topCentre  <- (0@0).
  57.         origin     <- (0@0).
  58.         topCentre x: ((maxW / 2) truncated); y: 150.
  59.         origin <- topCentre - (175@0).
  60.         maxW <- 350 min: ((origin x) + (maxW - 70)).
  61.         maxH <- 100 min: ((origin y) + (maxH - 70)).
  62.         nWindow <- Window new; 
  63.             title: aTitle;
  64.             openAt: origin withSize: (maxW@maxH).
  65.         self makePane
  66. |
  67.     makePane | ww wh |
  68.         self makePopMenu.
  69.         ww <- (nWindow size) x + 1.
  70.         wh <- (nWindow size) y + 1.
  71.         thePane  <- TextPane new;
  72.             boundsFrom: (-1 @ -1) to: (ww @ wh);
  73.             attachTo: nWindow withSizing: (1 @ 1) andLineLength: (80 * 9);
  74.             font: 'monaco'; fontSize: 9; print: theText;
  75.             button2Action: [:p | pMenu popUpAt: p ]
  76. |
  77.     makePopMenu
  78.         pMenu <- PopUpMenu new; create.
  79.         pMenu addItem: 'Close' 
  80.                   action: [ nWindow close ];
  81.               addItem: 'Debug' 
  82.                  action: [ ^ nil ];
  83.               disableItem: 2
  84. ]
  85.